// MgrFactory import javax.naming.InitialContext; import javax.rmi.PortableRemoteObject; import dwarf.DwarfMgr; import dwarf.MountainMgr; import dwarf.DwarfMgrHome; import dwarf.MountainMgrHome; public class MgrFactory { public static DwarfMgr getDwarfMgr(){ try { InitialContext jndiContext = new InitialContext(); Object ref = jndiContext.lookup("dwarf/DwarfMgr"); DwarfMgrHome home = (DwarfMgrHome)PortableRemoteObject.narrow(ref, DwarfMgrHome.class); return home.create(); }catch (Exception e) { // hack throw new RuntimeException("Naming Failure: " + e.getMessage()); } } public static MountainMgr getMountainMgr(){ try { InitialContext jndiContext = new InitialContext(); Object ref = jndiContext.lookup("dwarf/MountainMgr"); MountainMgrHome home = (MountainMgrHome)PortableRemoteObject.narrow(ref, MountainMgrHome.class); return home.create(); }catch (Exception e) { // hack throw new RuntimeException("Naming Failure: " + e.getMessage()); } } static { System.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); System.setProperty("java.naming.provider.url","jnp://localhost:1099"); System.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); } }